<template>
  <div class="content">
    <div class="topBanner">
      <div class="top-center">
        <span>News Information</span>
      </div>
      <div class="line">
        <div class="top-line1" />
        <div class="top-line2" />
      </div>
    </div>
    <div class="artral">
      <div class="artral-left">
        <div class="goBack" @click="goBack">return</div>
        <div class="left-top">
          <div class="left-date">
            {{ articleDetial.publishedTime }}
          </div>
          <div class="left-icon">
            <span class="el-icon-circle-plus" />
            <span class="el-icon-position" />
            <span class="el-icon-user-solid" />
            <span class="el-icon-plus" />
          </div>
        </div>
        <div class="left-center">
          <h4 v-html="articleDetial.title">
            {{ articleDetial.title }}
          </h4>
          <div v-if="!articleDetial.content" class="nodata">
            <img style="width: 20%;" src="@/assets/loginImgs/nodata.png" alt="">
          </div>
          <p v-html="articleDetial.content">
            <!-- {{ articleDetial.content }} -->
          </p>
        </div>
        <div class="left-bottom">
          <div class="left-icon">
            <span class="el-icon-circle-plus" />
            <span class="el-icon-position" />
            <span class="el-icon-user-solid" />
            <span class="el-icon-plus" />
          </div>
        </div>
      </div>
      <div class="artral-right">
        <div class="right-title">
          <p>The latest article</p>
        </div>
        <div class="right-name">
          <div v-if="!latestList.length" class="nodata mtNodata">
            <img style="width: 30%;" src="@/assets/loginImgs/nodata.png" alt="">
          </div>
          <ul>
            <li v-for="item in latestList" :key="item.id">
              <span @click="goCategoryDetial(item.id, item.title)">{{
                item.title
              }}</span>
            </li>
          </ul>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { articleRead, articleTextLatest } from '@/api/article';
export default {
  data() {
    return {
      detialId: '',
      articleDetial: {},
      latestList: []
    };
  },
  mounted() {
    this.detialId = parseInt(this.$route.query.id);
    this.getDetial(this.detialId);
    this.getLatest();
  },
  methods: {
    getLatest() {
      articleTextLatest().then((res) => {
        this.latestList = res.data.data;
      });
    },
    goCategoryDetial(id, title) {
      this.getDetial(id);
      // this.$router.push({
      //   path: '/home/faq',
      //   query: {
      //     id: id,
      //     title: title,
      //     type: 'other'
      //   }
      // });
    },
    getDetial(id) {
      articleRead(id).then((res) => {
        if (res.code === 200) {
          this.articleDetial = res.data;
          this.articleDetial.publishedTime = this.articleDetial.publishedTime.split(
            ' '
          )[0];
        }
      });
    },
    goBack() {
      history.go(-1);
    }
  }
};
</script>
<style lang="scss" scoped>
.nodata {
  text-align: center;
  margin-top: 50px;
}
.mtNodata {
  margin-top: calc(100vw / 32);
}
p, span {
  word-wrap: break-word;
}
.content {
  width: 100%;
  height: 100%;
  min-width: 1200px;
  margin-top: 70px;
  padding-bottom: 30px;
  background: rgba(249, 249, 249, 1);
  font-family: Segoe UI;
}
::v-deep .left-center {
  p {
    // word-wrap: break-word;
    img {
      object-fit: cover;
      max-width: 100% !important;
    }
  }
}
.topBanner {
  text-align: center;
  height: 400px;
  background: url("../../assets/loginImgs/news.png") no-repeat;
  background-size: 100% 100%;
  overflow: hidden;
  .top-center {
    font-size: 80px;
    font-weight: bold;
    line-height: 80px;
    color: #000000;
    margin-top: 70px;
    opacity: 1;
  }
  .line {
    width: 930px;
    margin: 0 auto;
    .top-line1 {
      width: 930px;
      height: 8px;
      margin-top: 25px;
      background: rgba(0, 0, 0, 1);
      opacity: 1;
    }
    .top-line2 {
      width: 630px;
      height: 8px;
      margin-top: 45px;
      background: rgba(0, 0, 0, 1);
      opacity: 1;
    }
  }
}
.artral {
  width: 1200px;
  margin: 50px auto 0 auto;
  // margin-top: calc(100vw / 38.4);
  // display: flex;
  // flex-flow: row;
  // justify-content: space-between;
  vertical-align: top;
  &-left {
    width: 800px;
    display: inline-block;
    padding: 0 20px;
    background: rgba(255, 255, 255, 1);
    box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.16);
    opacity: 1;
    position: relative;
    border-radius: 4px 0px 4px 4px;
    .goBack {
      height: 23px;
      width: 90px;
      text-align: center;
      font-size: 14px;
      font-weight: bold;
      line-height: 23px;
      position: absolute;
      right: 0;
      top: -23px;
      color: white;
      background: #02a152;
      cursor: pointer;
      border-radius: 4px 4px 0 0;
    }
    .left-top {
      margin: 0 auto;
      display: flex;
      line-height: 60px;
      justify-content: space-between;
      border-bottom: 1px solid rgba(230, 230, 230, 1);
    }
    .left-center {
      min-height: 600px;
      line-height: calc(100vw / 71.11);
      font-size: calc(100vw / 106.67);
      color: rgba(102, 102, 102, 1);
      padding-bottom: calc(100vw / 128);
    }
    .left-bottom {
      border-bottom: 1px solid rgba(230, 230, 230, 1);
      padding-bottom: 10px;
      text-align: right;
      .left-icon {
        width: 100%;
      }
    }
    .left-date {
      font-size: 18px;
      padding: 0 10px;
      color: rgba(102, 102, 102, 1);
      opacity: 1;
      display: inline-block;
      border-bottom: 4px solid rgba(2, 161, 82, 1);
    }
    .left-icon {
      display: inline-block;
      span {
        padding: 0 5px;
        color: goldenrod;
      }
    }
  }
  &-right {
    width: 360px;
    min-height: 300px;
    padding: 10px 40px;
    background: #ffffff;
    box-shadow: 0px 0px 4px rgba(0, 0, 0, 0.16);
    opacity: 1;
    border-radius: 4px;
    vertical-align: top;
    display: inline-block;
    margin-left: 30px;
    .right-title {
      // width: calc(100vw / 5.89);
      margin: 0 auto;
      text-align: center;
      font-size: 20px;
      // line-height: 60px;
      color: rgba(51, 51, 51, 1);
      border-bottom: 2px solid rgba(112, 112, 112, 1);
      p {
        padding-bottom: 15px;
      }
    }
    .right-name {
      line-height: 25px;
      ul {
        li {
          margin-bottom: 10px;
          color: #02a152;
        }
      }
    }
  }
}
</style>
